#include "SymmetryVoter.h"

SymmetryVoter::SymmetryVoter( PointSignature sigA, PointSignature sigB )
{
	psA = sigA;
	psB = sigB;
}


Vec3d SymmetryVoter::firstPoint()
{
	return psA.p;
}


Vec3d SymmetryVoter::secondPoint()
{
	return psB.p;
}


int SymmetryVoter::firstID()
{
	return psA.idx;
}

int SymmetryVoter::secondID()
{
	return psB.idx;
}

bool SymmetryVoter::reflection( Vec4d &trans )
{
	// plane: a*x + b*y + c*z + d = 0
	Vec3d n = (psA.p - psB.p).normalized();
	Vec3d mid = (psA.p + psB.p) / 2;
	double d = -dot(mid, n);

	// To-do: filter out bad reflection

	trans = Vec4d(n[0], n[1], n[2], d);

	return true;
}

